/**
 * 
 */

package com.chengyu.eyc.listener;

import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.chengyu.eyc.queue.RabbitMQConfig;
import com.chengyu.eyc.socket.EycWebSocketHandler;

import lombok.extern.slf4j.Slf4j;

/**
 * @author kevin
 *
 */
@Slf4j
@Component
public class MessageQueueListener {

    @Autowired
    EycWebSocketHandler eycWebSocketHandler;

    @RabbitListener(queues = RabbitMQConfig.MESSAGE_QUEUE)
    @RabbitHandler
    public void process(String message) {
        try {
            log.info("消息内容：{}", message);
            eycWebSocketHandler.sendFanoutMessage(message);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }

    }

}
